<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>注册页面 - Thor后台管理系统</title>
<link rel="icon" href="/static/favicon.ico" type="image/ico">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/static/css/animate.css" rel="stylesheet">
<link href="/static/css/style.min.css" rel="stylesheet">
<style>
.lyear-wrapper {
    position: relative;
}
.lyear-login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
}
.login-center {
    background: #fff;
    min-width: 38.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em 0;
}
.login-header {
    margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
}
</style>
</head>
  
<body>
<div class="row lyear-wrapper">
  <div class="lyear-login">
    <div class="login-center">
      <div class="login-header text-center">
        <a href="javascript:;"> <img alt="light year admin" src="/static/images/logo-sidebar.png"> </a>
      </div>
      <form method="post" id="login_form">
        <div class="form-group has-feedback feedback-left">
          <input type="text" placeholder="用户名" class="form-control" name="userName" id="userName" />
          <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="password" placeholder="密码" class="form-control" id="userPassword" name="userPassword" />
          <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <label class="lyear-radio radio-inline radio-primary">
            <input type="radio" name="userSex" value="男" checked>
            <span>男</span>
          </label>
          <label class="lyear-radio radio-inline radio-primary">
            <input type="radio" name="userSex" value="女">
            <span>女</span>
          </label>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="email" placeholder="邮件" class="form-control" id="userEmail" name="userEmail" />
          <span class="mdi mdi-email form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="tel" placeholder="手机号" class="form-control" id="userPhone" name="userPhone" />
          <span class="mdi mdi-phone form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <div class="col-xs-5">状态</div>
          <div class="col-xs-push-7">
            <label class="lyear-switch switch-solid switch-info">
              <input type="checkbox" name="userType" id="userType" checked disabled>
              <span></span>
            </label>
          </div>
        </div>
        <input type="text" style="display: none" id="departmentId" name="departmentId" value="3">
        <div class="form-group has-feedback feedback-left row">
          <div class="col-xs-7">
            <input type="text" name="captcha" class="form-control" placeholder="验证码">
            <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="col-xs-5">
            <div id="v_container" style="width: 130px;height: 38px;"></div>
          </div>
        </div>
        <div class="form-group">
          <button id="log_btn" class="btn btn-block btn-primary" type="button" onclick="reg();"><label><i class="mdi mdi-account-plus"></i></label>立即注册</button>
        </div>
      </form>
      <hr>
      <footer class="col-sm-12 text-center">
        <p class="m-b-0" style="font-size: 12px;color: #a5b3c7">Copyright © 2019 LiJunYi<a href="http://www.beian.miit.gov.cn/">&nbsp;&nbsp;浙ICP备19020174号</a></p>
      </footer>
    </div>
  </div>
</div>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<!--消息提示-->
<script src="/static/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/static/js/lightyear.js"></script>
<script type="text/javascript" src="/static/js/main.min.js"></script>
<!--验证码-->
<script type="text/javascript" src="/static/js/gVerify.js"></script>
<script type="text/javascript" src="/static/js/background.js"></script>
<script type="text/javascript">
  /*初始化验证码*/
  var verifyCode = new GVerify("v_container");
  /*注册方法*/
  function reg(){
    var res = verifyCode.validate($("input[name$='captcha']").val());
    let userType = $("#userType").val();
    if("on" == userType){
        userType = 1;
    }
    let user = {
      userName:$("#userName").val(),
      userPassword:$("#userPassword").val(),
      userSex:$("input[name='userSex']:checked").val(),
      userEmail:$("#userEmail").val(),
      userPhone:$("#userPhone").val(),
      userType:userType,
      departmentId:$("#departmentId").val()
    };
    if(res){
      if(user.userName == "" || user.userPassword == ""){
        lightyear.notify('请正确填写完注册信息', 'danger', 2000, 'mdi mdi-close-circle-outline', 'top', 'center');
        return;
      }
      $.ajax({
        url:"/reg_user",
        type:"post",
        cache:false,
        data:user,
        success:function (obj) {
          if("ok" == obj){
            lightyear.notify('注册成功，页面即将自动跳转', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
            setTimeout(function () {
              window.location.href="/page/login";
            },1500);
          }else{
            lightyear.notify(obj, 'danger', 2000, 'mdi mdi-close-circle-outline', 'top', 'center');
          }
        }
      });
    }else{
      lightyear.notify('验证码错误!', 'danger', 2000, 'mdi mdi-close-circle-outline', 'top', 'center');
    }
  }
</script>
</body>
</html>